<?php
require_once 'DBConnecter.inc';
class DB2Excel extends DBConnecter {
	function __construct() {
		$this->connectDB ();
		// $this->selectDB ( 'devdog' );
	}
	public function printExcel($objPHPExcel, $type, $sDate, $eDate) {
		$sql = "CALL " . self::CONST_DB . ".search_all('" . $type . "','" . $sDate . "','" . $eDate . "');";
		// echo $sql;
		$i = 2;
		if ($rs = $this->getMySqlConneter ()->multi_query ( $sql )) {
			if ($rs != null && $rs = $this->getMySqlConneter ()->use_result ()) {
				while ( $row = $rs->fetch_row () ) {
					switch ($type) {
						case 1 :
							$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, $row ['0'])        
                                  ->setCellValue('B' . $i, $row ['1'])
                                  ->setCellValue('C' . $i, $row ['2'])          
                                  ->setCellValue('D' . $i, $row ['3'])        
                                  ->setCellValue('E' . $i, $row ['4'])        
	                              ->setCellValue('F' . $i, $row ['5'])   
                                  ->setCellValue('G' . $i, $row ['6'])   
                                  ->setCellValue('H' . $i, $row ['7'])      
	                              ->setCellValue('I' . $i, $row ['8'])      
                                  ->setCellValue('J' . $i, $row ['9'])        
                                  ->setCellValue('K' . $i, $row ['10'])        
	                              ->setCellValue('L' . $i, $row ['11'])         
                                  ->setCellValue('M' . $i, $row ['12'])         
                                  ->setCellValue('N' . $i, $row ['13'])          
	                              ->setCellValue('O' . $i, $row ['14'])         
                                  ->setCellValue('P' . $i, $row ['15'])       
                                  ->setCellValue('Q' . $i, $row ['16'])       
	                              ->setCellValue('R' . $i, $row ['17'])        
	                              ->setCellValue('S' . $i, $row ['18'])         
	                              ->setCellValue('T' . $i, $row ['19'])          
	                              ->setCellValue('U' . $i, $row ['20'])       
	                              ->setCellValue('V' . $i, $row ['21'])       
	                              ->setCellValue('W' . $i, $row ['22'])     
	                              ->setCellValue('X' . $i, $row ['23'])     
	                              ->setCellValue('Y' . $i, $row ['24'])     
	                              ->setCellValue('Z' . $i, $row ['25'])      
	                              ->setCellValue('AA' . $i, $row ['26'])       
	                              ->setCellValue('AB' . $i, $row ['27'])        
	                              ->setCellValue('AC' . $i, $row ['28'])      
	                              ->setCellValue('AD' . $i, $row ['29'])     
	                              ->setCellValue('AE' . $i, $row ['30'])   
	                              ->setCellValue('AF' . $i, $row ['31'])       
	                              ->setCellValue('AG' . $i, $row ['32'])     
	                              ->setCellValue('AH' . $i, $row ['33'])     
	                              ->setCellValue('AI' . $i, $row ['34'])       
	                              ->setCellValue('AJ' . $i, $row ['35'])        
	                              ->setCellValue('AK' . $i, $row ['36'])   
	                              ->setCellValue('AL' . $i, $row ['37'])     
	                              ->setCellValue('AM' . $i, $row ['38'])     
	                              ->setCellValue('AN' . $i, $row ['39'])        
	                              ->setCellValue('AO' . $i, $row ['40'])        
	                              ->setCellValue('AP' . $i, $row ['41'])       
	                              ->setCellValue('AQ' . $i, $row ['42'])      
	                              ->setCellValue('AR' . $i, $row ['43']) 
	                              ->setCellValue('AS' . $i, $row ['44'])        
	                              ->setCellValue('AT' . $i, $row ['45'])        
	                              ->setCellValue('AU' . $i, $row ['46'])       
	                              ->setCellValue('AV' . $i, $row ['47'])       
	                              ->setCellValue('AW' . $i, $row ['48'])       
	                              ->setCellValue('AX' . $i, $row ['49'])       
	                              ->setCellValue('AY' . $i, $row ['50']);
							break;
						case 2 :
							$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, $row ['0'])
							->setCellValue('B' . $i, $row ['1'])
							->setCellValue('C' . $i, $row ['2'])
							->setCellValue('D' . $i, $row ['3'])
							->setCellValue('E' . $i, $row ['4'])
							->setCellValue('F' . $i, $row ['5'])
							->setCellValue('G' . $i, $row ['6'])
							->setCellValue('H' . $i, $row ['7'])
							->setCellValue('I' . $i, $row ['8'])
							->setCellValue('J' . $i, $row ['9'])
							->setCellValue('K' . $i, $row ['10'])
							->setCellValue('L' . $i, $row ['11'])
							->setCellValue('M' . $i, $row ['12'])
							->setCellValue('N' . $i, $row ['13'])
							->setCellValue('O' . $i, $row ['14'])
							->setCellValue('P' . $i, $row ['15'])
							->setCellValue('Q' . $i, $row ['16'])
							->setCellValue('R' . $i, $row ['17'])
							->setCellValue('S' . $i, $row ['18'])
							->setCellValue('T' . $i, $row ['19'])
							->setCellValue('U' . $i, $row ['20'])
							->setCellValue('V' . $i, $row ['21'])
							->setCellValue('W' . $i, $row ['22'])
							->setCellValue('X' . $i, $row ['23'])
							->setCellValue('Y' . $i, $row ['24'])
							->setCellValue('Z' . $i, $row ['25'])
							->setCellValue('AA' . $i, $row ['26'])
							->setCellValue('AB' . $i, $row ['27'])
							->setCellValue('AC' . $i, $row ['28'])
							->setCellValue('AD' . $i, $row ['29'])
							->setCellValue('AE' . $i, $row ['30']);
							break;
						case 3 :
							$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, $row ['0'])
							->setCellValue('B' . $i, $row ['1'])
							->setCellValue('C' . $i, $row ['2'])
							->setCellValue('D' . $i, $row ['3'])
							->setCellValue('E' . $i, $row ['4'])
							->setCellValue('F' . $i, $row ['5'])
							->setCellValue('G' . $i, $row ['6'])
							->setCellValue('H' . $i, $row ['7'])
							->setCellValue('I' . $i, $row ['8'])
							->setCellValue('J' . $i, $row ['9'])
							->setCellValue('K' . $i, $row ['10'])
							->setCellValue('L' . $i, $row ['11'])
							->setCellValue('M' . $i, $row ['12']);
							break;
						case 4 :
							$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, $row ['0'])
							->setCellValue('B' . $i, $row ['1'])
							->setCellValue('C' . $i, $row ['2'])
							->setCellValue('D' . $i, $row ['3'])
							->setCellValue('E' . $i, $row ['4'])
							->setCellValue('F' . $i, $row ['5'])
							->setCellValue('G' . $i, $row ['6'])
							->setCellValue('H' . $i, $row ['7'])
							->setCellValue('I' . $i, $row ['8'])
							->setCellValue('J' . $i, $row ['9'])
							->setCellValue('K' . $i, $row ['10'])
							->setCellValue('L' . $i, $row ['11'])
							->setCellValue('M' . $i, $row ['12'])
							->setCellValue('N' . $i, $row ['13'])
							->setCellValue('O' . $i, $row ['14'])
							->setCellValue('P' . $i, $row ['15'])
							->setCellValue('Q' . $i, $row ['16'])
							->setCellValue('R' . $i, $row ['17'])
							->setCellValue('S' . $i, $row ['18'])
							->setCellValue('T' . $i, $row ['19'])
							->setCellValue('U' . $i, $row ['20'])
							->setCellValue('V' . $i, $row ['21'])
							->setCellValue('W' . $i, $row ['22'])
							->setCellValue('X' . $i, $row ['23'])
							->setCellValue('Y' . $i, $row ['24'])
							->setCellValue('Z' . $i, $row ['25'])
							->setCellValue('AA' . $i, $row ['26'])
							->setCellValue('AB' . $i, $row ['27'])
							->setCellValue('AC' . $i, $row ['28'])
							->setCellValue('AD' . $i, $row ['29'])
							->setCellValue('AE' . $i, $row ['30'])
							->setCellValue('AF' . $i, $row ['31'])
							->setCellValue('AG' . $i, $row ['32'])
							->setCellValue('AH' . $i, $row ['33'])
							->setCellValue('AI' . $i, $row ['34'])
							->setCellValue('AJ' . $i, $row ['35'])
							->setCellValue('AK' . $i, $row ['36'])
							->setCellValue('AL' . $i, $row ['37'])
							->setCellValue('AM' . $i, $row ['38'])
							->setCellValue('AN' . $i, $row ['39'])
							->setCellValue('AO' . $i, $row ['40'])
							->setCellValue('AP' . $i, $row ['41'])
							->setCellValue('AQ' . $i, $row ['42'])
							->setCellValue('AR' . $i, $row ['43'])
							->setCellValue('AS' . $i, $row ['44'])
							->setCellValue('AT' . $i, $row ['45'])
							->setCellValue('AU' . $i, $row ['46'])
							->setCellValue('AV' . $i, $row ['47'])
							->setCellValue('AW' . $i, $row ['48'])
							->setCellValue('AX' . $i, $row ['49'])
							->setCellValue('AY' . $i, $row ['50'])
							->setCellValue('AZ' . $i, $row ['51'])
							->setCellValue('BA' . $i, $row ['52'])
							->setCellValue('BB' . $i, $row ['53'])
							->setCellValue('BC' . $i, $row ['54'])
							->setCellValue('BD' . $i, $row ['55'])
							->setCellValue('BE' . $i, $row ['56'])
							->setCellValue('BF' . $i, $row ['57'])
							->setCellValue('BG' . $i, $row ['58'])
							->setCellValue('BH' . $i, $row ['59'])
							->setCellValue('BI' . $i, $row ['60'])
							->setCellValue('BJ' . $i, $row ['61'])
							->setCellValue('BK' . $i, $row ['62'])
							->setCellValue('BL' . $i, $row ['63'])
							->setCellValue('BM' . $i, $row ['64'])
							->setCellValue('BN' . $i, $row ['65'])
							->setCellValue('BO' . $i, $row ['66'])
							->setCellValue('BP' . $i, $row ['67'])
							->setCellValue('BQ' . $i, $row ['68'])
							->setCellValue('BR' . $i, $row ['69'])
							->setCellValue('BS' . $i, $row ['70'])
							->setCellValue('BT' . $i, $row ['71'])
							->setCellValue('BU' . $i, $row ['72'])
							->setCellValue('BV' . $i, $row ['73'])
							->setCellValue('BW' . $i, $row ['74']);
							break;
					}
					$i ++;
				}
				$rs->free ();
			}
		}
	}
}


